package Bean.pop;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.sz.lxit.LinkDB.ConnectionManage;

public class Power {	
	public AllPopBean creatPower(int role,ConnectionManage tool)
	{
		Connection nec = null;
		Statement  st = null;
		ResultSet  re = null;
		
		AllPopBean all = new AllPopBean();
		AdminBean admin = null;
			SmallModelBean small= null;
		JiangchengBean  jiang= null;
			SmallModelBean jilu=null;
			SmallModelBean query=null;
		KaoqinBean kaoqin = null;
			SmallModelBean qiandao = null;
			SmallModelBean daoquery = null;
			SmallModelBean qianli = null;
			SmallModelBean liquery = null;
		PayBean paymanage = null;
			SmallModelBean jisuan = null;
			SmallModelBean fafang = null;
			SmallModelBean payquery = null;
		ShijiaBean shijia = null;
			SmallModelBean shijiaadd = null;
			SmallModelBean shijiaquery = null;
		SysBean system = null;
			SmallModelBean jichu = null;
			SmallModelBean kaoqinxinzi = null;
			SmallModelBean kaoqinshijian = null;
			SmallModelBean shijiaxinzi = null;
			SmallModelBean jiangchengxinzi = null;
			SmallModelBean gangweixinzi = null;
		UsBean users = null;
			SmallModelBean  zhigongguanli = null;
			SmallModelBean  lizhiguanli = null;
		
		try {
			nec = tool.getConnection();
			st = nec.createStatement();
			
			re=st.executeQuery("select * from pop where pop_part="+role);			
	

			while (re.next())
			{	
				int model=(int)re.getInt("pop_model");
				
				if (model >= 1 && model <=27)
				{
					if (model == 1)
					{
						system=all.getSb();
						jichu=system.getJichu();
						kaoqinxinzi=system.getKaoqinxinzi();
						kaoqinshijian=system.getKaoqinshijian();
						shijiaxinzi=system.getShijiaxinzi();
						jiangchengxinzi=system.getJiangchengxinzi();
						gangweixinzi=system.getGangweixinzi();
						system.setSwitchs(1);
					}
					else if (model == 2)
					{
						jichu.setSwitchs(1);
					}
					else if (model == 3)
					{
						jichu.setQuery(1);
					}
					else if (model == 4)
					{
						jichu.setAdd(1);
					}
					else if (model == 5)
					{
						jichu.setAmend(1);
					}
					else if (model == 6)
					{
						jichu.setDelete(1);
					}
					else if (model == 7)
					{
						kaoqinshijian.setSwitchs(1);
					}
					else if (model == 8)
					{
						kaoqinshijian.setQuery(1);
					}
					else if (model == 9)
					{
						kaoqinshijian.setAdd(1);
					}
					else if (model == 10)
					{
						kaoqinxinzi.setSwitchs(1);								
					}
					else if (model == 11)
					{
						kaoqinxinzi.setQuery(1);
					}
					else if (model == 12)
					{
						kaoqinxinzi.setAdd(1);
					}
					else if (model == 13)
					{
						shijiaxinzi.setSwitchs(1);
					}
					else if (model == 14)
					{
						shijiaxinzi.setQuery(1);
					}
					else if (model == 15)
					{
						shijiaxinzi.setAdd(1);
					}
					else if (model == 16)
					{
						shijiaxinzi.setAmend(1);
					}
					else if (model == 17)
					{
						shijiaxinzi.setDelete(1);
					}
					else if (model == 18)
					{
						jiangchengxinzi.setSwitchs(1);
					}
					else if (model == 19)
					{
						jiangchengxinzi.setQuery(1);
					}
					else if (model == 20)
					{
						jiangchengxinzi.setAdd(1);
					}
					else if (model == 21)
					{
						jiangchengxinzi.setAmend(1);
					}
					else if (model == 22)
					{
						jiangchengxinzi.setDelete(1);
					}
					else if (model == 23)
					{
						gangweixinzi.setSwitchs(1);
					}
					else if (model == 24)
					{
						gangweixinzi.setQuery(1);
					}
					else if (model == 25)
					{
						gangweixinzi.setAdd(1);
					}
					else if (model == 26)
					{
						gangweixinzi.setAmend(1);
					}
					else if (model == 27)
					{
						gangweixinzi.setDelete(1);
					}
				}
				else if (model >= 28 && model <= 38)
				{
					if (model == 28)
					{
						users = all.getUsb();
						zhigongguanli = users.getZhigongguanli();
						lizhiguanli = users.getLizhiguanli();
						users.setSwitchs(1);
					}
					else if (model == 29)
					{
						zhigongguanli.setSwitchs(1);
					}
					else if (model == 30)
					{
						zhigongguanli.setQuery(1);
					}
					else if (model == 31)
					{
						zhigongguanli.setAdd(1);
					}
					else if (model == 32)
					{
						zhigongguanli.setAmend(1);
					}
					else if (model == 33)
					{
						zhigongguanli.setDelete(1);
					}
					else if (model == 34)
					{
						lizhiguanli.setSwitchs(1);
					}
					else if (model == 35)
					{
						lizhiguanli.setQuery(1);
					}
					else if (model == 36)
					{
						lizhiguanli.setAdd(1);
					}
					else if (model == 37)
					{
						lizhiguanli.setAmend(1);
					}
					else if (model == 38)
					{
						lizhiguanli.setDelete(1);
					}
				}
				else if (model >=39 && model <=47)
				{
					if (model == 39)
					{
						kaoqin=all.getKqb();
						qiandao=kaoqin.getQiandaoguanli();
						daoquery=kaoqin.getQiandaochaxun();
						qianli=kaoqin.getQianliguanli();
						liquery=kaoqin.getQianlichaxun();
						kaoqin.setSwitchs(1);
					}
					else if (model == 40)
					{
						qiandao.setSwitchs(1);
					}
					else if (model == 41)
					{
						qiandao.setAdd(1);
					}
					else if (model == 42)
					{
						daoquery.setSwitchs(1);
					}
					else if (model ==43)
					{
						daoquery.setQuery(1);
					}
					else if (model == 44)
					{
						qianli.setSwitchs(1);
					}
					else if (model == 45)
					{
						qianli.setAdd(1);
					}
					else if (model ==46)
					{
						liquery.setSwitchs(1);
					}
					else if (model == 47)
					{
						liquery.setQuery(1);
					}
				}
				else if (model>=48 && model<=52)
				{
					if (model == 48)
					{
						shijia = all.getSjb();
						shijiaadd=shijia.getTianjiashijiajilu();
						shijiaquery=shijia.getShijiajiluchaxun();
						shijia.setSwitchs(1);
					}
					else if (model == 49)
					{
						shijiaadd.setSwitchs(1);
					}
					else if (model == 50)
					{
						shijiaadd.setAdd(2);
					}
					else if (model == 51)
					{
						shijiaquery.setSwitchs(1);
					}
					else if (model==52)
					{
						shijiaquery.setQuery(1);
					}
				}
				else if (model>=53 && model<=57)
				{
					if (model == 53)
					{
						jiang=all.getJcb();
						jilu=jiang.getJiangchengjilu();
						query=jiang.getJiangchengchaxun();
						jiang.setSwitchs(1);
						
					}
					else if (model == 54)
					{
						jilu.setSwitchs(1);
						
					}
					else if (model == 55)
					{
						jilu.setAdd(1);
					}
					else if (model == 56)
					{
						query.setSwitchs(1);
					}
					else if (model == 57)
					{
						query.setQuery(1);								
					}
				}
				else if (model >=58 && model <=66)
				{
					if (model == 58)
					{
						paymanage=all.getPay();
						jisuan=paymanage.getGongzijisuan();
						fafang=paymanage.getGongzifafang();
						payquery=paymanage.getGongzichakan();
						paymanage.setSwitchs(1);
					}
					else if (model == 59)
					{
						jisuan.setSwitchs(1);
					}
					else if (model == 60)
					{
						jisuan.setQuery(1);
					}
					else if (model == 61)
					{
						jisuan.setAdd(1);
					}
					else if (model == 62)
					{
						fafang.setSwitchs(1);
					}
					else if (model == 63)
					{
						fafang.setQuery(1);
					}
					else if (model == 64)
					{
						fafang.setAdd(1);
					}
					else if (model == 65)
					{
						payquery.setSwitchs(1);
					}
					else if (model == 66)
					{
						payquery.setQuery(1);
					}
					else if (model == 67)
					{
						payquery.setAdd(1);
					}
				}
				else if (model>=68 && model<=73)
				{
					if (model == 68)
					{
						admin = all.getAb();								
						small= admin.getXitongguanli();
						admin.setSwitchs(1);
					}
					else if (model == 69)
					{
						small.setSwitchs(1);
					}
					else if (model == 70)
					{
						small.setQuery(1);
					}
					else if (model == 71)
					{
						small.setAdd(1);
					}
					else if (model == 72)
					{
						small.setAmend(1);
					}
					else if (model == 73)
					{
						small.setDelete(1);
					}
				}
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			if (tool != null)
			{
				try {
					tool.closeConnection(nec);
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}

		return all;
	}
}
